Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(resolve): allow overriding enhanced-resolve's options #384

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

GertSallaerts
Copy link

@GertSallaerts GertSallaerts commented Nov 14, 2024

Allows you to customize the config for module resolution. See: https://github.com/webpack/enhanced-resolve?tab=readme-ov-file#resolver-options


Old description (the PR was initially intended to only specify the modules option)

Allows you to do things like:

  • Use bower components
  • Specify your app's src folder as a modules folder and require('models/foo'); from within your src folder

Basically this: https://webpack.js.org/configuration/resolve/#resolvemodules

That second bullet point used to be possible by just setting resolvePaths but going from this comment on #139 that was considered an unintended side-effect or bug.

@GertSallaerts GertSallaerts changed the title feat(resolve): allow specifying enhanced-resolver's modules option feat(resolve): allow specifying enhanced-resolve's modules option Nov 14, 2024
@scagood scagood self-assigned this Nov 14, 2024
@scagood
Copy link

scagood commented Nov 14, 2024

Thank you for you PR!

I will review it first thing tomorrow morning.

scagood

This comment was marked as resolved.

Copy link

@scagood scagood left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me 👍

@GertSallaerts GertSallaerts changed the title feat(resolve): allow specifying enhanced-resolve's modules option feat(resolve): allow overriding enhanced-resolve's options Nov 15, 2024

Override the options generated by this plugin for resolving require and import statements. These
options are passed down to `enhanced-resolve`'s factory method and are documented [here on their
GitHub repository](https://github.com/webpack/enhanced-resolve?tab=readme-ov-file#resolver-options).

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm a bit concerned that this will over-bind this package to enhanced-resolve, which may make it harder for us to make changes in the future - e.g. moving to import.meta.resolve (which I remember it has been discussed somewhere before).

We can state the minimum necessary in the docs. wdty?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess the minimum necessary really depends on everyone's specific use cases. For us (and why I made this PR) it would be specifying resolverConfig.modules to add an additional path for modules lookup. For another user it might be any of the 25 options documented in enhanced-resolve's README.

Or did you mean something else by the minimum neccesary?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, I think resolverConfig.modules is enough for now. I don't feel that the implementation has to be changed as well - other options can be something like undocumented features. thoughts? /cc @scagood

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants